﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace PizzaService.Model
{
    /// <summary>
    /// Implementiert INotifyPropertyChanged
    /// </summary>
    public class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void RaisePropertyChanged<TResult>(Expression<Func<TResult>> propertyExpression)
        {
            RaisePropertyChanged(((MemberExpression)propertyExpression.Body).Member.Name);
        }
    }
}
